package com.tensquare;

import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.tensquare.spit.SpitApplicaiton;
import org.bson.Document;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;



/**
 * @Description:
 * @Author: xuxiaoyu
 * @Date: 2019/11/25 14:34
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpitApplicaiton.class)
public class test {
    @Test
    public void test1(){
        MongoClient client=new MongoClient("192.168.254.129");//创建连接
        MongoDatabase spitdb = client.getDatabase("spitdb");//打开数据库
        MongoCollection<Document> spit = spitdb.getCollection("spit");//获取集合
        FindIterable<Document> documents = spit.find();//查询记录获取文档集合
    }
}
